package test

import scala.collection.mutable._

object ListDemo2 {
  def main(args: Array[String]): Unit = {
    var list=ListBuffer(1,2,3,4,500)
    println(list)
    list(1)=100
    list.append(532)
    println("修改后:")
    println(list)
    list.remove(3);
    println("删除后:")
    println(list)
    var l2=list.drop(4)//删除的个数
    println("删除后")
    println(l2)
    var l3=list.dropRight(2);
    println(l3)
    println(">>>>>>>>>>>>>>>>>>>>>>>")
    list+=14//加右边
    list+=15
    23+=:list
    23+=:list
    700+=:list
    100+=:list

    999+=:list
    List(66,77)++=:list//加左边
    println("增加后：")
    println(list)
    println("减法后：")
    list-=14
    println(list)
    println("size:"+list.size);
    println("group::::")
    var x=list grouped(3)
    for(a1<- x){
      println(a1)
    }
    println("sliding")
    var y=list sliding(2)
    for(a1<- y){
      println(a1)
    }
    var l4=list.sorted(Ordering.Int.reverse)
    println("排序后："+l4)
    var l5=list.sortWith(_<_)
    println("排序后："+l5)

    println("group by:")
    //var l6=list.groupBy(x=>x%5==0);
    var l6=list.groupBy(_%5==0);
    for(z<-l6){
      println(z)
    }

  }
}
